<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>日志管理</title>
    <meta name="decorator" content="nblank"/>
</head>
<body>
<!-- 	<ul class="nav nav-tabs"> -->
<%-- 		<li class="active"><a href="${ctx}/sys/log/">日志列表</a></li> --%>
<!-- 	</ul> -->
<div class="content container">
    <h2 class="page-title">日志管理
        <small> 日志列表</small>
    </h2>
    <section class="widget widget-tabs widget-table-overflow ">
        <div class="body tab-content">

                <form:form id="searchForm" action="${ctx}/sys/log/" method="post" class=" form-search">

                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
          <div class="widget" style="margin-bottom: 10px;">
                <div class="form-group row" style="margin-top: 10px;">
                    <label class="control-label col-sm-2 text-right">操作菜单：</label>
                    <div class="col-sm-2">
                        <input id="title" name="title" type="text" class="form-control input-transparent"
                               value="${log.title}"/>
                    </div>
                    <label class="control-label col-sm-1 text-right">用户ID：</label>
                    <div class="col-sm-2">
                        <input id="createBy.id" name="createBy.id" type="text" class="form-control input-transparent"
                               value="${log.createBy.id}"/>
                    </div>
                    <label class="control-label col-sm-1 text-right">URI：</label>
                    <div class="col-sm-2">
                        <input id="requestUri" name="requestUri" type="text" class="form-control input-transparent"
                               value="${log.requestUri}"/>
                    </div>
                    <div class="col-sm-3"></div>
                </div>
                <div class="form-group row" style="margin-top:8px;">
                    <div class="row form-inline ">
                        <div class="control-label col-sm-2 text-right" style="margin-left: 10px">
                            <label>日期范围：</label>
                        </div>
                        <div class="input-group date col-sm-2 timeb1">
                            <input id="beginDate" name="beginDate" type="text" readonly="readonly" maxlength="20" htmlEscape="false" size="32" class="form-control input-transparent"/>
                            <div class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></div>
                            <div class="input-group-addon"><span class="glyphicon glyphicon-time"></span></div>
                        </div>
                        <span>-</span>
                        <div class="input-group date col-sm-2 timeb1">
                            <input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20" htmlEscape="false" size="32" class="form-control input-transparent"/>
                            <div class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></div>
                            <div class="input-group-addon"><span class="glyphicon glyphicon-time"></span></div>
                        </div>

                        <div class="input-group col-sm-2 col-md-offset-1">
                            <div class="checkbox checkbox-primary">
                                    <span>
                                        <input id="exception" name="exception" class="checkbox-primary" type="checkbox" value="1">
                                        <label for="roleIdList1">只查询异常信息</label>
                                    </span>
                                <input type="hidden" name="_roleIdList" value="on">
                            </div>
                        </div>
                        <div class="input-group col-sm-2">
                            <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
                        </div>
                    </div>
                 </div>
          </div>
                    </form:form>

                <sys:message content="${message}"/>
            <div class="widget" style="margin-bottom: 6px;">
                <table id="contentTable" class="table table-striped table-condensed">
                    <thead>
                    <tr>
                        <th>操作菜单</th>
                        <th>操作用户</th>
                        <th>所在公司</th>
                        <th>所在部门</th>
                        <th>URI</th>
                        <th>提交方式</th>
                        <th>操作者IP</th>
                        <th>操作时间</th>
                    </thead>
                    <tbody><%
                        request.setAttribute("strEnter", "\n");
                        request.setAttribute("strTab", "\t");
                    %>
                    <c:forEach items="${page.list}" var="log">
                        <tr>
                            <td>${log.title}</td>
                            <td>${log.createBy.name}</td>
                            <td>${log.createBy.company.name}</td>
                            <td>${log.createBy.office.name}</td>
                            <td><strong>${log.requestUri}</strong></td>
                            <td>${log.method}</td>
                            <td>${log.remoteAddr}</td>
                            <td><fmt:formatDate value="${log.createDate}" type="both"/></td>
                        </tr>
                        <c:if test="${not empty log.exception}">
                            <tr>
                                <td colspan="8" style="word-wrap:break-word;word-break:break-all;">
                                        <%-- 					用户代理: ${log.userAgent}<br/> --%>
                                        <%-- 					提交参数: ${fns:escapeHtml(log.params)} <br/> --%>
                                    异常信息: <br/>
                                        ${fn:replace(fn:replace(fns:escapeHtml(log.exception), strEnter, '<br/>'), strTab, '&nbsp; &nbsp; ')}
                                </td>
                            </tr>
                        </c:if>
                    </c:forEach>
                    </tbody>
                </table>

                <div class="row">${page}</div>
            </div>
            </div>
    </section>
</div>
<script type="text/javascript">
    function page(n, s) {
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
<script type="text/javascript" src="${ctxStatic}/datetimepicker/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="${ctxStatic}/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
    var endTimeValue = "";
    var datetime=new Date();
    var timeRight = '';
    var year = datetime.getFullYear();
    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
    var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();
    var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
    timeRight = year + "-" + month + "-" + date+" "+hour+":"+minute;
    //    console.info(timeRight);
    var timeb1 =  $('.timeb1').datetimepicker({
        autoclose:true,
        format: "yyyy-mm-dd hh:ii",
        language:  'zh-CN',
        startView: 3,
        minView: 0,
        maxView: 4,
        forceParse: 0,
        startDate: "2016-01-01 00:00",
        linkFormat: "yyyy-mm-dd hh:ii:ss"
    }).on('changeDate', function(e){
//        timee1.datetimepicker("setStartDate",e.date);
//        var startTime=$("#beginDate").val();
//        console.info("$(beginDate).val()-------"+$("#beginDate").val());
//        timee1.datetimepicker("setStartDate",startTime);
//        console.info("timeb1 endDate-------"+e.startDate);
//        console.info("timeb1 endDate-------"+e.endDate);
    });
    var timee1 =  $('.timee1').datetimepicker({
        disabled:true,
        autoclose:true,
        format: "yyyy-mm-dd hh:ii",
        language:  'zh-CN',
        startView: 3,
        minView: 0,
        maxView: 4,
        forceParse: 0,
        startDate: "2016-01-01 00:00",
        linkFormat: "yyyy-mm-dd hh:ii:ss"
    }).on('changeDate', function(e){
        var endDate=$("#endDate").val();
//        console.info("$(endDate).val()-------"+$("#endDate").val());
//        $('.timee1').datetimepicker('setEndDate','2016-07-02');
    });
</script>
</body>
</html>